home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Screensavers 98
/
Screensavers 98.iso
/
scr
/
pyro
/
firemain.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-03-28
|
44KB
|
1,133 lines
// *** Fire work Demostration Screen Saver Program ***
// ***** Written by Steven De Toni Febyary 1996 ******
// ***************************************************
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// ***** Include object information *****
#include "config.h" // Configuration file define constants
#include "ctl3d.h" // Fancey look to dialog boxes in Win3.1.
#include "fclasses.h"
#include "fix.h"
// Program varibales !
const char* pSzProgName = "Fire Work Screen Saver"; // Program name.
const int StrSize = 256; // String size for string processing.
static HINSTANCE HInst; // Handle to main window of application.
// *** Prototypes ***
long FAR PASCAL _export WndProc (HWND hWnd, WORD message, WORD wParam, LONG lParam);
BOOL FAR PASCAL _export ConfigDialog (HWND hDlg, WORD message, WORD wParam, LONG lParam);
BOOL FAR PASCAL _export SetPasswordDialog (HWND hDlg, WORD message, WORD wParam, LONG lParam);
BOOL FAR PASCAL _export GetUserPDialog (HWND hDlg, WORD message, WORD wParam, LONG lParam);
int UpdateField (HWND hDlg, int cntlID, int direction, int heightLimit, int lowLimit);
// Spinner and field entry limits in configuration dialog.
const int ObjRocketMax = 9000, ObjRocketMin = 0;
const int ObjFlowerMax = 9000, ObjFlowerMin = 0;
const int ObjFlareMax = 9000, ObjFlareMin = 1;
const int ObjTrailerMax = 50, ObjTrailerMin = 1;
const int ObjLifeMax = 2000, ObjLifeMin = 10;
const int ObjPicSizeMax = 4, ObjPicSizeMin = 1;
const int PicFreqMax = 10, PicFreqMin = 1;
const int PicAngleMax = 20, PicAngleMin = -20;
const int FrameRate = 0;
// Default INI settings.
const char* Section = "Configuration";
const char* DefIniSettings = "1 50 10 50 1 50 10 100 1 ~ 0";
// Timer ID constant.
const int TIMERMAIN = 10; // Timer ID within function.
const int TIMERABOUT = 11;
const int TIMERCONFIG = 12;
// Time limit variables for entering password.
const long PASSWORDCYCLIMIT = 3000; // Timit limit to enter password before dialod is removed.
static long CurrentCycle = 0;
static HWND HPassDialog = NULL; // Varible used to commincate with
// Password dialog box, and close it
// after a certain time. If variable is
// not null, then password dialog box is
// open.
// Current system screen size.
int MAXX, MAXY;
// Configuration variables for screen saver.
// These variables are stored in the INI file (win.ini)
static int RocketNum;
static int RocketFlareNum;
static int RocketTrailLen;
static int RocketLifeCount;
static int FlowerNum;
static int FlowerFlareNum;
static int FlowerTrailLen;
static int FlowerLifeCount;
extern int PixelSize; // Pixel size of objects, definied in class definition file.
static char Password [StrSize/5];
static int UsePassword;
// ***************************************************************************************
// Program Entry, and exit.
// ***************************************************************************************
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
char paramBuff[StrSize];
HInst = hInstance; // Assign program instance
randomize();
if (!hPrevInstance)
{
wndclass.style = CS_BYTEALIGNWINDOW | CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC) WndProc;
wndclass.cbClsExtra = 0;
wndclass.hInstance = HInst;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (HInst, MAKEINTRESOURCE(BLANKCURSOR));
wndclass.hbrBackground = GetStockObject (BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = pSzProgName;
RegisterClass (&wndclass);
}
else
return 0; // Don't more than one instance of the screen saver
MAXX = GetSystemMetrics(SM_CXSCREEN);
MAXY = GetSystemMetrics(SM_CYSCREEN);
// Check parameter string for configuration command /c
lstrcpy (paramBuff, lpszCmdParam);
strupr (paramBuff);
if (strstr (paramBuff, "/C") != NULL)
{
// Setup the control 3D sub-classing DLL.
Ctl3dRegister(HInst);
Ctl3dAutoSubclass(HInst);
// Test Configuration Dialog.
static FARPROC fpfnConfigDialog;
fpfnConfigDialog = MakeProcInstance ((FARPROC)ConfigDialog, HInst);
DialogBox (HInst, MAKEINTRESOURCE(IDD_CONFIGDIALOG), NULL, (DLGPROC) fpfnConfigDialog);
FreeProcInstance (fpfnConfigDialog);
// Free up usage count of 3D DLL.
Ctl3dUnregister(HInst);
return 0;
}
// Create Screen Saver window.
hwnd = CreateWindowEx (WS_EX_TOPMOST,
pSzProgName, // Window class name
"", // Window caption
WS_POPUP, // Window style
0, // inital X position
0, // inital y position
MAXX, // inital X size
MAXY, // intial y size
NULL, // parent window handle
NULL, // window menu handle
HInst, // program instance handle
NULL); // creation parameters
// Setup Screen saver timer.
SetTimer(hwnd, TIMERMAIN, FrameRate, (TIMERPROC) WndProc);
// Go into screen saver mode.
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);
// Process screen saver messages...
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
// Pic one of the primary colours
COLORREF PicColour (void)
{
// select primary colour
switch (random(7))
{
case 0:
return RGB (255, 0, 0);
case 1:
return RGB (0, 255, 0);
case 2:
return RGB (0, 0, 255);
case 3:
return RGB (255, 255, 0);
case 4:
return RGB (0, 255, 255);
case 5:
return RGB (255, 0, 255);
case 6:
default:
return RGB (255, 255, 255);
}
}
// ***************************************************************************
// *** Get User Password Dialog Box. Open up the dialog box to recieve the
// *** user's password.
// ***************************************************************************
BOOL FAR PASCAL _export GetUserPDialog (HWND hDlg, WORD message, WORD wParam, LONG lParam)
{
switch (message)
{
case WM_INITDIALOG:
HPassDialog = hDlg;
CurrentCycle = 0;
SetActiveWindow (GetDlgItem(hDlg, IDC_GETPASSWORD));
return TRUE;
case WM_CHAR:
MessageBeep (-1);
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
return TRUE;
case WM_COMMAND: // A user has selected a control command
switch (LOWORD (wParam))
{
case IDC_CANCEL:
EndDialog (hDlg, FALSE);
HPassDialog = NULL;
return TRU